package com.kayt.cyberBar.cuser.business.dao.impl;

import java.sql.SQLException;
import java.util.LinkedHashMap;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import com.kayt.cyberBar.common.PageData;
import com.kayt.cyberBar.common.dao.EntityDao;
import com.kayt.cyberBar.cuser.business.dao.ISheetStoreHistoryWorkDao;
import com.kayt.cyberBar.cuser.business.entity.po.BSheetStoreHistoryWork;

@Repository("sheetStoreHistoryWorkDao")
public class SheetStoreHistoryWorkDaoImpl implements ISheetStoreHistoryWorkDao {
	@Autowired
	private EntityDao entityDao;

	@Override
	public Integer save(BSheetStoreHistoryWork entity) throws SQLException {
		if (entity != null) {
			entityDao.save(entity);
			return 0;
		} else {
			return -1;
		}
	}

	@Override
	public Integer update(BSheetStoreHistoryWork entity) throws SQLException {
		if (entity != null) {
			entityDao.update(entity);
			return 0;
		} else {
			return -1;
		}
	}

	@Override
	public Integer delete(Integer id) {

		if (id != null) {
			BSheetStoreHistoryWork BSheetStoreHistoryWork = findById(id);
			if (BSheetStoreHistoryWork != null) {
				entityDao.delete(BSheetStoreHistoryWork);
				return 0;
			} else {
				return -1;
			}
		} else {
			return -1;
		}
	}

	@Override
	public BSheetStoreHistoryWork findById(Integer id) {

		if (id != null) {
			return entityDao.findById(id, BSheetStoreHistoryWork.class);
		} else {
			return null;
		}
	}

	@Override
	public PageData<BSheetStoreHistoryWork> findByPage(int pageNum, int pageSize, String hql, Object[] params,
			LinkedHashMap<String, String> orderMap) throws SQLException {
		return this.entityDao.getPagingData(BSheetStoreHistoryWork.class, pageNum, pageSize, hql, params, orderMap);
	}
}
